package com.wy2.eclipse.tool.ui;

import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IStartup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.wy2.core.date.DateTime;
import com.wy2.core.date.TimeSpan;

public class UiStartup implements IStartup {
	private static final Logger logger = LoggerFactory.getLogger(UiStartup.class);

	@Override
	public void earlyStartup() {
		Display.getDefault().syncExec(new Runnable(){

            @Override
            public void run() {
                long eclipseStartTime = Long.parseLong(System.getProperty("eclipse.startTime"));
                DateTime startDateTime=new DateTime(eclipseStartTime);
                DateTime currentTime=DateTime.Now();
                logger.info("eclipse启动时间: {} ", startDateTime.toString());
                TimeSpan timeSpan = currentTime.Substract(startDateTime);
                double costTime = timeSpan.getTotalseconds();
                //timeSpan.getTotalMilliseconds()
                //Shell shell = Display.getDefault().getActiveShell();
                //String message = "ui eclipse 启动时间:" + costTime + "ms";
                //MessageDialog.openInformation(shell, "Information", message);
                logger.info("eclipse 启动用时: {} 秒",costTime);
            }
            
        });

	}

}
